package com.fz.consumer.listeners;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class FanoutMqListener {
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "fanout.queue1",durable = "true"),
            exchange = @Exchange(name = "test.fanout1", type = ExchangeTypes.FANOUT)
    ))
    public void fanoutExchangeListening(String msg){
        log.info("收到test.fanout1交换机绑定队列fanout.queue1的消息++++++++++++++:{}",msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "fanout.queue2",durable = "true"),
            exchange = @Exchange(name = "test.fanout1", type = ExchangeTypes.FANOUT)
    ))
    public void fanoutExchangeListening2(String msg){
        log.info("收到test.fanout1交换机绑定队列fanout.queue2的消息--------------:{}",msg);
    }
}
